//
// Created by Castle on 2025/10/21.
//

#include <bitset>
#include <iomanip>
#include <iostream>

int main() {

    const int COLUMN_WIDTH {20};

    unsigned char value1 {0x3}; // 0000 0011
    unsigned char value2 {0x5}; // 0000 0101

    std::cout << std::setw(COLUMN_WIDTH) << "value1: "
    << std::setw(COLUMN_WIDTH) << std::bitset<8>(value1) << std::endl;

    std::cout << std::setw(COLUMN_WIDTH) << "value2: "
    << std::setw(COLUMN_WIDTH) << std::bitset<16>(value2) << std::endl;

    // AND
    std::cout << std::endl;
    std::cout << "Bitwise AND: " << std:: endl;
    std::cout << std::setw(COLUMN_WIDTH) << "value1 & value2 :"
        << std::setw(COLUMN_WIDTH) << std::bitset<8>(value1 & value2) << std::endl;
    std::cout << std::endl;

    // OR
    std::cout << "Bitwise OR: " << std::endl;
    std::cout << std::setw(COLUMN_WIDTH) << "value1 | value2 :"
            << std::setw(COLUMN_WIDTH) << std::bitset<8>(value1 | value2) << std::endl;
    std::cout << std::endl;

    // NOT
    std::cout << "Bitwise NOT: " << std::endl;
    std::cout << std::setw(COLUMN_WIDTH) << "~value1 :"
        << std::setw(COLUMN_WIDTH) << std::bitset<8>(~value1) << std::endl;
    std::cout << std::setw(COLUMN_WIDTH) << "~value2 :"
        << std::setw(COLUMN_WIDTH) << std::bitset<8>(~value2) << std::endl;

    // XOR
    std::cout << "Bitwise XOR: " << std::endl;
    std::cout << std::setw(COLUMN_WIDTH) << "value1 ^ value2 :"
        << std::setw(COLUMN_WIDTH) << std::bitset<8>(value1 ^ value2) << std::endl;

    return 0;
}
